@file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE")

<%= render('kotlin/package.erb') %>

@JsModule("@trustwallet/wallet-core")
@JsName("<%= entity.name %>")
external interface Js<%= entity.name %> {
    val value: Number
    companion object {
<%  entity.cases.each do |c| -%>
        val <%= KotlinHelper.fix_name(WasmCppHelper.format_name(c.name)) %>: Js<%= entity.name %>
<%  end -%>
    }
}

inline val JsWalletCore.<%= entity.name %>: Js<%= entity.name %>.Companion
    get() = asDynamic().<%= entity.name %>.unsafeCast<Js<%= entity.name %>.Companion>()

<%  if entity.properties.any? || entity.methods.any? -%>
@JsModule("@trustwallet/wallet-core")
@JsName("<%= entity.name %>Ext")
external interface Js<%= entity.name %>Ext {
<%# Static method declarations -%>
<%- entity.properties.each do |property| -%>
    fun <%= KotlinHelper.fix_name(WasmCppHelper.format_name(property.name)) %>(<%= KotlinHelper.js_parameters(property.parameters) %>)<%= KotlinHelper.js_return_type(property.return_type) %>
<%- end -%>
<%  entity.methods.each do |method| -%>
<%    next if method.name.start_with?('Create') -%>
    fun <%= KotlinHelper.fix_name(WasmCppHelper.function_name(entity: entity, function: method)) %>(<%= KotlinHelper.js_parameters(method.parameters) %>)<%= KotlinHelper.js_return_type(method.return_type) %>
<%  end -%>
}

inline val JsWalletCore.<%= entity.name %>Ext: Js<%= entity.name %>Ext
    get() = asDynamic().<%= entity.name %>Ext.unsafeCast<Js<%= entity.name %>Ext>()

<%  end -%>